#!/usr/bin/python3
# -*- coding:utf-8 -*-
""""
@Author: 李吉凯
@Email:
@Time: 2021/8/18 16:37
@File: 年度自评_新增.py
"""

import BladeFerm.Lib.Common as Common
from BladeFerm.UI.NcPublic import *
from BladeFerm.utils.basic_opration import get_curtime


def test(input_data=None, ui_except=None, input_elements=None):
    logger.info(input_data)
    logger.info(input_elements)
    logger.info(ui_except)
    # 测试 报表预处理
    InputElements = input_data.get('Elements(Object)', None)
    InputData = input_data.copy()
    InputElement = eval(InputElements) if input_elements is None else input_elements
    UIExcept = ui_except.copy()
    # 进入主页
    openWebPage()
    # 打开菜单
    getMenu(InputData.get('菜单名字'), InputElement.get('菜单元素'))

    # 选择修改行元素
    rowElement = InputElement.get('列表元素').format(InputData.get('删除任务序号'))
    click(rowElement, '修改复选框')
    # 点击修改
    click(InputElement.get('删除按钮元素'), '删除按钮')
    confirm()

    # 断言成功与否
    checkAlterResult(UIExcept.get('校验结果'), InputElement.get('结果提示元素'))
    # 关闭浏览器
    close('关闭')

if __name__ == '__main__':
    word_space = config['ScriptsDir']['scripts_dir']
    file_path = "全面风险管理/内控评价ICE/内控评价管理/测试数据/年度自评_修改.xls"
    excel_path = os.path.join(word_space, file_path)
    input_data = Common.dealXlsElement(excel_path, value_id=2, sheet_index=1)
    input_elements = Common.dealXlsElement(excel_path, sheet_index=0)
    ui_except = Common.dealXlsElement(excel_path, value_id=2, sheet_index=2)
    test(input_data=input_data, ui_except=ui_except, input_elements=input_elements)